/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bookshop.facade;

import com.bookshop.entity.Category;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Thibault
 */
@Stateless
public class CategoryFacade extends AbstractFacade<Category> {
    @PersistenceContext(unitName = "BookShop-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CategoryFacade() {
        super(Category.class);
    }
    
    public String getNomCategorie(int identifiant){
        String sql = "Select c.label from Category c where c.id= :pid";
        String retour="";
        Query query = em.createQuery(sql);
        query.setParameter("pid",identifiant);
        retour = (String) query.getSingleResult();
        System.out.println("Ici le nom de categorie  : " +retour);
        return retour;
    }
    
}
